package com.zhome.gateway.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Json工具类
 * @author cuiyh9
 * @date 2020/5/14
 */
public class JsonUtil {

    private JsonUtil() {

    }

    /**
     * 将对象转为json字符串
     * @return
     */
    public static String toJsonString(Object obj) throws JsonProcessingException {
        ObjectMapper om = new ObjectMapper();
        String s = om.writeValueAsString(obj);
        return s;
    }
}
